package com.mlyol.prototype;

public class Demo1 {

    static class Sheep implements Cloneable{
        String name;
        int age;
        Sheep friend;

        public Sheep getFriend() {
            return friend;
        }

        public void setFriend(Sheep friend) {
            this.friend = friend;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }

        public Sheep(String name, int age) {
            this.name = name;
            this.age = age;
        }

        @Override
        public String toString() {
            return "Sheep{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }

    public static void main(String[] args) throws Exception {
        Sheep sheep=new Sheep("sb",1);
        Sheep sheep2 = (Sheep)sheep.clone();
        Sheep sheep3 = (Sheep)sheep.clone();
        Sheep sheep4 = (Sheep)sheep.clone();
        Sheep sheep5 = (Sheep)sheep.clone();
        System.out.println(sheep+" hashCode:"+sheep.hashCode());
        System.out.println(sheep2+" hashCode:"+sheep2.hashCode());
        System.out.println(sheep3+" hashCode:"+sheep3.hashCode());
        System.out.println(sheep4+" hashCode:"+sheep4.hashCode());
        System.out.println(sheep5+" hashCode:"+sheep5.hashCode());
    }

}
